home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 July
/
EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso
/
earcd
/
dev
/
amos
/
kyzeramo.lha
/
Strip.AMOS
/
Strip.amosSourceCode
Wrap
AMOS Source Code
|
1992-09-03
|
3KB
|
97 lines
' compile me!
If Screen=0 : Screen Close 0 : End If : Amos To Back
FILE$=Command Line$ : STRIP[FILE$] : End
'
Procedure STRIP[FILE$]
' STRIP procedure strips assembler files
' by Kyzer/CSG in July 1995.
' yeah, I _know_ it's really slow, but persevere, eh?
' it won't get any faster in AMOS, believe me.
'
If Not Exist(FILE$) Then Pop Proc
Erase 8 : Erase 9
Open In 1,FILE$ : L=Lof(1) : Close 1
Reserve As Work 8,L
Bload FILE$,Start(8)
Reserve As Work 9,L
S=Start(8) : SP=S : SE=S+Length(8)
D=Start(9) : DP=D
'
' turn all tabs to single spaces for ease.
For A=S To SE : If Peek(A)=9 : Poke A,32 : End If : Next
Repeat
Repeat
S$="" : D$=""
'
' get a line
Repeat
T$=Chr$(Peek(SP)) : S$=S$+T$ : Inc SP
Until T$=Chr$(10) or SP>=SE
'
' quick check
A$=Left$(S$,1)
Until(A$<>"*") and(A$<>";") and(A$<>Chr$(10))
'
' check for errors
ERR=False
N=True
For A=1 To Len(S$)
M=Asc(Mid$(S$,A,1))
If M=34 : N=Instr(S$,Chr$(34),A+1) : Exit If N=0 : A=N : End If
If M=39 : N=Instr(S$,Chr$(39),A+1) : Exit If N=0 : A=N : End If
Exit If M=59 or M=42
Next A
If N=0 Then D$=S$ : Goto WRITEBACK
'
' kill extra spaces
S$=S$+Chr$(10)
For A=1 To Len(S$)
M=Asc(Mid$(S$,A,1))
If M=34 : B=Instr(S$,Chr$(34),A+1)
D$=D$+Mid$(S$,A,B-A) : A=B : End If
'
If M=39 : B=Instr(S$,Chr$(39),A+1)
D$=D$+Mid$(S$,A,B-A) : A=B : End If
'
Exit If M=59 or M=42
Exit If M=10
'
If M=32 : Repeat : Inc A : M=Asc(Mid$(S$,A,1))
Until M=10 or M<>32 : Exit If M=10,1
D$=D$+" " : M=32 : Dec A : End If
'
If M<>32 : OA=A : Repeat : D$=D$+Chr$(M) : Inc A
M=Asc(Mid$(S$,A,1)) : Until M=32 or M=10 : Dec A : End If
Next A
'
' take up the three words alone (label, command, args)
D$=D$+" "
N=1
For A=1 To 3
M=Instr(D$," ",N)
If M Then N=M+1
Next A
D$=Left$(D$,N-2)
'
' swap equs for '='s
S$=D$ : A=Instr(Lower$(S$)," equ ")
If A Then D$=Left$(S$,A-1)+"="+Right$(S$,Len(S$)-A-4)
'
' final removal of excess stuff and addition of linefeed
D$=D$-Chr$(0) : D$=D$-Chr$(10)
Repeat : A=(Right$(D$,1)=" ") : If A : D$=Left$(D$,Len(D$)-1)
End If : Until A=False : D$=D$+Chr$(10)
'
' wahey! one line shortened!
WRITEBACK:
' if the line below is corrupted, delete it and uncomment the two
' below it.
If D$<>Chr$(10) : Extension_18_015A DP,D$ : DP=DP+Len(D$) : End If
' If D$<>Chr$(10) : For A=0 To Len(D$)-1 : Poke DP+A,Asc(Mid$(D$,A+1,1)
' Next A : DP=DP+Len(D$) : End If
Until SP>=SE
'
' writeback to disk
If Exist(FILE$) Then Kill FILE$
Bsave FILE$,Start(9) To DP
End Proc